<template>
	<page-meta :page-style="themeColor"></page-meta>
	<view :style="{ minHeight: openBottomNav ? 'calc(100vh - 55px)' : '' }" class="page-img">
		<!-- <view class="site-info-box" v-if="$util.isWeiXin() && followOfficialAccount && followOfficialAccount.isShow && wechatQrcode">
			<view class="site-info">
				<view class="img-box" v-if="siteInfo.logo_square">
					<image :src="$util.img(siteInfo.logo_square)" mode="aspectFill"/>
				</view>
				<view class="info-box" :style="{ color: '#ffffff' }">
					<text class="font-size-base">{{ siteInfo.site_name }}</text>
					<text>{{ followOfficialAccount.welcomeMsg }}</text>
				</view>
			</view>
			<view class="dite-button" @click="officialAccountsOpen">关注公众号</view>
		</view> -->


		<!-- <view class="page-header" v-if="diyData.global && diyData.global.navBarSwitch" :style="{ backgroundImage: bgImg }">
			<ns-navbar :title-color="textNavColor" :data="diyData.global" :scrollTop="scrollTop" :isBack="false"/>
		</view> -->
		<view class="top-banner">
			<view>
				<image :src="$util.image('/upload/ico/logo.jpg')" class="logo-image" />
			</view>
			<view class="title-section">
				<view class="main-title">医启通</view>
				<view class="sub-title">您的健康·我的追求</view>
			</view>
		</view>
		<view class="main-container">
			<view class="" style="width: 94%;margin-left: 3%;">
				<view class="address-text">当前地址：{{ currentAddress }}</view>
				<view>
					<uv-swiper :list="bannerList" keyName="url" :height="160" :interval="30000" :radius="20"
						:circular="true"></uv-swiper>
					</div>

					<view class="medical-supplies" @click="goToPage()">
						<image :src="$util.image('/upload/ico/home1.png')" class="supplies-image" mode="widthFix" />
					</view>
				</view>
			</view>
			<view class="">
				<view>
					<image :src="$util.image('/upload/ico/nav.png')" mode="widthFix" class="nav-image" />
				</view>
				<image :src="$util.image('/upload/ico/home4.png')" class="" style="width: 100%;padding-bottom: 150rpx;margin-top: 0;"
					mode="widthFix" />
			</view>
		</view>

		<!-- 底部tabBar -->
		<view class="page-bottom" v-if="openBottomNav">
			<diy-bottom-nav @callback="callback" :name="name" />
		</view>

		<!-- 关注公众号弹窗 -->
		<view @touchmove.prevent class="official-accounts-inner" v-if="wechatQrcode">
			<uni-popup ref="officialAccountsPopup" type="center">
				<view class="official-accounts-wrap">
					<image class="content" :src="$util.img(wechatQrcode)" mode="aspectFit"></image>
					<text class="desc">关注了解更多</text>
					<text class="close iconfont icon-round-close" @click="officialAccountsClose"></text>
				</view>
			</uni-popup>
		</view>

		<!-- 收藏 -->
		<uni-popup ref="collectPopupWindow" type="top" class="wap-floating wap-floating-collect">
			<view v-if="showTip" class="collectPopupWindow"
				:style="{ marginTop: (collectTop + statusBarHeight) * 2 + 'rpx' }">
				<image :src="$util.img('public/uniapp/index/collect2.png')" mode="aspectFit" />
				<text @click="closeCollectPopupWindow">我知道了</text>
			</view>
		</uni-popup>

		<!-- 选择门店弹出框，定位当前位置，展示最近的一个门店 -->
		<view @touchmove.prevent.stop class="choose-store">
			<uni-popup ref="chooseStorePopup" type="center" :maskClick="false" class="choose-store">
				<view class="choose-store-popup" v-if="currentStore">
					<view class="head-wrap">请确认门店</view>
					<view class="position-wrap">
						<text class="iconfont icon-dizhi"></text>
						<text class="address">{{ currentPosition || currentStore.show_address }}</text>
						<view class="reposition" @click="reGetLocation"
							v-if="globalStoreConfig && globalStoreConfig.is_allow_change == 1">
							<text class="iconfont icon-dingwei"></text>
							<text>重新定位</text>
						</view>
					</view>
					<view class="store-wrap" v-if="currentStore">
						<text class="tag">当前门店</text>
						<view class="store-name">{{ currentStore.store_name }}</view>
						<view class="store-close-desc" v-if="currentStore.status == 0 && currentStore.close_desc">
							{{ currentStore.close_desc }}
						</view>
						<view class="address">{{ currentStore.show_address }}</view>
						<view class="distance" v-if="currentStore.distance">
							<text class="iconfont icon-dizhi"></text>
							<text>{{ currentStore.distance > 1 ? currentStore.distance + 'km' : currentStore.distance * 1000 + 'm' }}</text>
						</view>
					</view>
					<button type="primary" @click="closeChooseStorePopup">确认进入</button>
					<view class="other-store" @click="chooseOtherStore"
						v-if="globalStoreConfig && globalStoreConfig.is_allow_change == 1">
						<text>选择其他门店</text>
						<text class="iconfont icon-right"></text>
					</view>
				</view>
			</uni-popup>
		</view>
		<!-- 连锁门店未开启定位或定位失败弹框 -->
		<view @touchmove.prevent.stop class="chain-stores">
			<uni-popup ref="getLocationFailRef" type="bottom" :maskClick="false" class="choose-store">
				<view class="chain-store-popup">
					<view class="title">获取位置失败</view>
					<view class="body">
						<view class="center">
							<view class="image">
								<image width="341rpx" :src="$util.img('public/uniapp/index/no_location_tips.png')"
									mode="aspectFit" />
							</view>
							<view class="text-top">系统暂时定位不到您的位置</view>
							<view class="text-bottom" v-if="mapConfig.wap_is_open == 1">
								请确认定位服务已经打开或者您可手动选择附近的门店以便我们提供更精确的服务</view>
							<view class="text-bottom" v-else>请手动选择附近的门店以便我们提供更精确的服务</view>
							<view class="footer">
								<button :type="mapConfig.wap_is_open == 1?'default':'primary'"
									@click="chooseStore">选择门店</button>
								<button v-if="mapConfig.wap_is_open == 1" type="primary" class="btn-right"
									@click="openSetting">开启定位</button>
							</view>

						</view>
					</view>
				</view>
			</uni-popup>
		</view>
		<!-- #ifdef MP-WEIXIN -->
		<!-- 小程序隐私协议 -->
		<privacy-popup ref="privacyPopup"></privacy-popup>
		<!-- #endif -->


	</view>
</template>

<script>
	import uniPopup from '@/components/uni-popup/uni-popup.vue';
	import nsNavbar from '@/components/ns-navbar/ns-navbar.vue';
	import diyJs from '@/common/js/diy.js';
	import indexJs from './public/js/index.js';

	export default {
		components: {
			uniPopup,
			nsNavbar
		},
		mixins: [diyJs, indexJs],
		data() {
			return {
				currentAddress: '未选择地址',
				bannerList: []
			};
		},
		onLoad(option) {
			uni.setStorageSync('qrcode_id', option.scene)
			uni.removeStorageSync('departmentInfo');
			if (option.scene) {
				//查询二维码信息
				this.$api.sendRequest({
					url: '/api/address/qrcode',
					data: {
						id: option.scene
					},
					success: res => {
						this.currentAddress = res.data
					},
				});
			}
			this.$api.sendRequest({
				url: '/api/adv/banner',
				data: {},
				success: res => {
					this.bannerList = res.data
				},
			});
		},
		onShow() {
			let departmentInfo = uni.getStorageSync('departmentInfo');
			if (departmentInfo) {
				this.currentAddress = departmentInfo.name
			}
		},
		methods: {
			// handleAddressConfirm(address){
			// 	uni.setStorageSync('departmentInfo',{id:address.id,name:address.name});
			// 	this.currentAddress = address.name
			// }
			goToPage() {
				console.log("111111111")
				uni.switchTab({
					url: '/pages/goods/category'
				})
			}
		}
	};
</script>

<style lang="scss">
	@import '@/common/css/diy.scss';
	@import './public/css/index.scss';
</style>
<style scoped>
	.wap-floating>>>.uni-popup__wrapper.uni-custom .uni-popup__wrapper-box {
		background: none !important;
	}

	.choose-store>>>.goodslist-uni-popup-box {
		width: 80%;
	}

	/deep/.diy-index-page .uni-popup .uni-popup__wrapper-box {
		border-radius: 0;
	}

	/deep/ .placeholder {
		height: 0;
	}

	/deep/::-webkit-scrollbar {
		width: 0;
		height: 0;
		background-color: transparent;
		display: none;
	}

	/deep/ .sku-layer .uni-popup__wrapper.uni-custom .uni-popup__wrapper-box {
		max-height: unset !important;
	}

	/deep/ .chain-stores .uni-popup__mask {
		backdrop-filter: blur(10rpx);
	}

	/deep/ .chain-stores .uni-popup__wrapper.uni-custom.bottom .uni-popup__wrapper-box,
	.uni-popup__wrapper.uni-custom.top .uni-popup__wrapper-box {
		max-height: 100vh !important;
	}

	/* 顶部背景区域 */
	.top-banner {
		height: 400rpx;
		background-color: #0893ff;
		border-radius: 0 0 100rpx 100rpx;
		color: white;
		display: flex;
		flex-direction: row;
	}

	/* logo图片样式 */
	.logo-image {
		height: 110rpx;
		margin: 100rpx 0 0 50rpx;
		border-radius: 30rpx;
		width: 120rpx;
	}

	/* 标题区域 */
	.title-section {
		margin: 100rpx 0 0 30rpx;
		color: white;
	}

	/* 主标题 */
	.main-title {
		color: white;
		font-size: 20px;
		font-weight: 400;
	}

	/* 副标题 */
	.sub-title {
		color: #ffffffc2;
	}

	/* 主要内容容器 */
	.main-container {
		width: 100%;
		position: absolute;
		top: 250rpx;
	}

	/* 地址显示 */
	.address-text {
		text-align: center;
		color: white;
	}

	/* 轮播图容器 */
	.swiper-container {
		margin: 20rpx 0 0 0;
		width: 100%;
	}

	/* 医疗耗材区域 */
	.medical-supplies {
		display: flex;
		flex-direction: row;
		margin: 0 auto;
	}

	/* 医疗耗材图片 */
	.supplies-image {
		margin: 20rpx 0rpx 0 0;
		width: 100%;
	}

	/* 医疗耗材内容区域 */
	.supplies-content {
		display: flex;
		flex-direction: column;
	}

	/* 医疗耗材标题 */
	.supplies-title {
		color: #0893ff;
		font-size: 34rpx;
	}

	/* 医疗耗材描述 */
	.supplies-desc {
		color: #303133b5;
	}

	/* 导航图片 */
	.nav-image {
		margin: 20rpx 0 0 0;
		width: 100%;
	}
</style>